//
// Created by sjjmw on 3/24/2022.
//
#include "iostream"
#include "vector"
#include "list"
#include "algorithm"
#include "string"
#include "unordered_map"
#include "cmath"
#include<iomanip>
#include "string"
#include "map"
#include "list"

int get_char_v(char c){
    if(c>='0'&&c<='9'){
        return c-'0';
    }
    return c-'A'+10;
}
struct Sol{
    int jinzhi;
    std::vector<int> plus_rev(std::vector<int> vec){
        int jinwei=0;
        std::vector<int> ret;
        for(int i=0;i<vec.size();i++){
            int m=vec[i]+vec[vec.size()-1-i]+jinwei;
            ret.push_back(m%jinzhi);
            jinwei=m/jinzhi;
        }
        if(jinwei){
            ret.push_back(jinwei);
        }

        return ret;
    }
    bool ishuiwen(std::vector<int> vec){
        for(int i=0;i<vec.size()/2;i++){
            if(vec[vec.size()-i-1]!=vec[i]){
                return false;
            }
        }
        return true;
    }
    void handle(int jinzhi1){
        this->jinzhi=jinzhi1;

        std::string str;
        std::getline(std::cin,str);
        std::getline(std::cin,str);

        std::vector<int> num_vec;
        for(int i=str.size();i>0;i--){
            num_vec.push_back(get_char_v(str[i-1]));
        }
        int step=0;
        while(1){
            if(ishuiwen(num_vec)){
                printf("STEP=%d",step);
                break;
            }else{

                if(step==30){
                    printf("Impossible!");
                    break;
                }
                num_vec= plus_rev(num_vec);
                step++;
            }
        }
    }
};
int main(){
    int a,b,c;
    while(std::cin>>a){
        Sol().handle(a);
    }

    return 0;
}